package cn.gson.boot.model.pojos;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.List;
import java.util.Objects;

@Entity
@Table(name = "user_", schema = "boot", catalog = "")
public class User {
    private int empId;//员工编号
    private String empName;//员工名称
    private String empPwd;//密码
    private String empPhone;//电话号码
    private String empIdentity;//用户身份证
    private Timestamp empTime;//注册时间
    private String empJob;//是否在职
    private String empSex;//性别
    private String empAddress;//员工地址
    private Dept deptId;//部门id

    private String empImg;//头像

    private List<Kehu> kehuList;//客户对象

    private List<Role> roles;
    public String jsList;

    @ManyToMany
    @JoinTable(name = "yuangong_juese",
            joinColumns = {@JoinColumn(name="emp_id")},
            inverseJoinColumns = {@JoinColumn(name = "jue_id")})
    public List<Role> getRoles() {
        return roles;
    }

    public void setRoles(List<Role> roles) {
        this.roles = roles;
    }

    //一个员工可能有多个客户
    @OneToMany(mappedBy = "empId")
    public List<Kehu> getKehuList() {
        return kehuList;
    }

    public void setKehuList(List<Kehu> kehuList) {
        this.kehuList = kehuList;
    }

    public User(String empName, String empPwd) {
        this.empName = empName;
        this.empPwd = empPwd;
    }

    public User() {
    }

    public User(int empId) {
        this.empId = empId;
    }

    @Id
    @Column(name = "emp_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY,generator = "seq")
    public int getEmpId() {
        return empId;
    }

    public void setEmpId(int empId) {
        this.empId = empId;
    }

    @Basic
    @Column(name = "emp_name", nullable = true, length = 200)
    public String getEmpName() {
        return empName;
    }

    public void setEmpName(String empName) {
        this.empName = empName;
    }

    @Basic
    @Column(name = "emp_pwd", nullable = true, length = 200)
    public String getEmpPwd() {
        return empPwd;
    }

    public void setEmpPwd(String empPwd) {
        this.empPwd = empPwd;
    }

    @Basic
    @Column(name = "emp_phone", nullable = true, length = 200)
    public String getEmpPhone() {
        return empPhone;
    }

    public void setEmpPhone(String empPhone) {
        this.empPhone = empPhone;
    }

    @Basic
    @Column(name = "emp_identity", nullable = true, length = 200)
    public String getEmpIdentity() {
        return empIdentity;
    }

    public void setEmpIdentity(String empIdentity) {
        this.empIdentity = empIdentity;
    }

    @Basic
    @Column(name = "emp_time", nullable = false)
    public Timestamp getEmpTime() {
        return empTime;
    }

    public void setEmpTime(Timestamp empTime) {
        this.empTime = empTime;
    }

    @Basic
    @Column(name = "emp_job", nullable = true)
    public String getEmpJob() {
        return empJob;
    }

    public void setEmpJob(String empJob) {
        this.empJob = empJob;
    }

    @Basic
    @Column(name = "emp_sex", nullable = true, length = 200)
    public String getEmpSex() {
        return empSex;
    }

    public void setEmpSex(String empSex) {
        this.empSex = empSex;
    }

    @Basic
    @Column(name = "emp_address", nullable = true, length = 200)
    public String getEmpAddress() {
        return empAddress;
    }

    public void setEmpAddress(String empAddress) {
        this.empAddress = empAddress;
    }


    @ManyToOne
    @JoinColumn(name = "dept_id", referencedColumnName = "dept_id")
    public Dept getDeptId() {
        return deptId;
    }

    public void setDeptId(Dept deptId) {
        this.deptId = deptId;
    }


    @Column(name = "emp_img")
    public String getEmpImg() {
        return empImg;
    }

    public void setEmpImg(String empImg) {
        this.empImg = empImg;
    }
}
